package com.hopes.bizz.listener;

import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hopes.bizz.position.position.dto.ReceiveDataDTO;
import com.hopes.bizz.position.position.dto.ReceiveRtPositionDTO;
import com.hopes.boss.admin.api.dto.SysLogDTO;
import com.hopes.common.receive.enums.DataTypeEnum;
import com.hopes.common.receive.event.ReceiveLogEvent;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor
public class ReceiveLogListener implements ApplicationListener<ReceiveLogEvent> {

    @Override
    public void onApplicationEvent(@NotNull ReceiveLogEvent event) {
        final DataTypeEnum dataTypeEnum = event.getDataTypeEnum();
        if (ObjUtil.isNull(dataTypeEnum) || !dataTypeEnum.equals(DataTypeEnum.EMPLOYEE_LOCATIONS)) {
            return;
        }
        SysLogDTO sysLogDTO = event.getSysLogDTO();
        String params = sysLogDTO.getParams();
        if (StrUtil.isBlank(params)) {
            return;
        }
        ReceiveRtPositionDTO receiveRtPositionDTO = JSON.parseObject(params, ReceiveRtPositionDTO.class);

    }
}
